#ifndef  __DEFINE_H__
#define  __DEFINE_H__

#include "io_model.h"

#include<sys/types.h>
#include<sys/socket.h>
#include<arpa/inet.h>
#include<netinet/in.h>
#include<netinet/ip.h>
#include<sched.h>
#include<map>
#include<dirent.h>
#include<string.h>
#include<assert.h>
#include<ctype.h>
#include<unistd.h>
#include<fcntl.h>
#include<iomanip>
#include<iterator>
#include<vector>
#include<stdarg.h>
#include<sys/syscall.h>
#include<errno.h>

#define CMD_CHECK  0xFF
#define DEBUG_LEVEL  1

//返回值;
namespace RET{
	static const int SUCCESS = 0;
	static const int FAIL = -1;
}


//配置类选项的枚举
enum configOption{
	LISTEN_IP_ADDR = 0,
	LISTEN_PORT,
	PROCESS_THREAD_NUM,
	LISTEN_THREAD_NUM,
	THREAD_PRIORITY,
	THREAD_STACK_SIZE,
	THREAD_SCHEDULE_POLICY,
	ACCESS_LOG_PATH,
	ERROR_LOG_PATH,
	WRITE_LOG_LEVEL,
	CMD_1,
	CMD_2,
	CMD_3,
	CMD_4,
	CMD_5,
	CMD_6,
	CMD_7,
	CMD_8,
	CMD_9
};

//线程上下文;
struct pthread_ctx{
	//线程属性;
	//调度策略;
	//优先级;
	//绑定到的cpu;
	//回调函数;
	//线程id;
	int policy;
	struct sched_param param;
	pthread_attr_t attr;
	int cpuno;
	cpu_set_t mask; //集合;
	void *(*func)(void *arg);
	void *arg;
	pthread_t id;
};

//监听套接字;
struct socket_st{
	int fd;
	struct sockaddr_in addr;
	struct socket_st *next;
};

/**
 * @brief 日志配置管理结构体;
 */
struct log_conf_st
{
	char *pAccessLogPath; //访问日志的路径;
	char *pErrorLogPath;
	int iWriteLogLevel;
};


#define DEBUG_TRACE( x , y ) do { \
	flockfile(stdout); \
	if ( (x) > DEBUG_LEVEL ) { \
		printf  y; \
	} \
	funlockfile(stdout); \
}while(0)


//event Type
enum eventType{
	NETWORKCONNECTION = 0,
	INIT = 1,
	ERROR = 2,
	RUN
};





#endif 
